/*   1:    */ package tt.dz.web.controller.financial;
/*   2:    */ 
/*   3:    */ import com.alibaba.fastjson.JSON;
/*   4:    */ import com.alibaba.fastjson.JSONObject;
/*   5:    */ import java.util.ArrayList;
/*   6:    */ import java.util.HashMap;
/*   7:    */ import java.util.List;
/*   8:    */ import java.util.Map;
/*   9:    */ import javax.annotation.Resource;
/*  10:    */ import javax.servlet.http.HttpServletRequest;
/*  11:    */ import javax.servlet.http.HttpServletResponse;
/*  12:    */ import org.apache.commons.lang3.StringUtils;
/*  13:    */ import org.apache.shiro.SecurityUtils;
/*  14:    */ import org.apache.shiro.session.Session;
/*  15:    */ import org.apache.shiro.subject.Subject;
/*  16:    */ import org.springframework.stereotype.Controller;
/*  17:    */ import org.springframework.web.bind.annotation.RequestMapping;
/*  18:    */ import org.springframework.web.bind.annotation.ResponseBody;
/*  19:    */ import tt.dz.biz.service.account.AccountService;
/*  20:    */ import tt.dz.biz.service.account.AssetsLbltsAccountRuleService;
/*  21:    */ import tt.dz.biz.service.financial.AccountTransferService;
/*  22:    */ import tt.dz.common.DateUtil;
/*  23:    */ import tt.dz.common.LogUtil;
/*  24:    */ import tt.dz.vo.AccountTransferVO;
/*  25:    */ import tt.dz.vo.AccountingRuleVO;
/*  26:    */ import tt.dz.vo.AssetsLbltsAccountRuleVO;
/*  27:    */ import tt.dz.vo.ResponseModle;
/*  28:    */ import tt.dz.vo.SubAccountingRuleVO;
/*  29:    */ import tt.dz.vo.TranInfoVO;
/*  30:    */ import tt.dz.vo.TranSubVO;
/*  31:    */ import tt.dz.web.controller.BaseController;
/*  32:    */ 
/*  33:    */ @Controller
/*  34:    */ public class AccountingController
/*  35:    */   extends BaseController
/*  36:    */ {
/*  37:    */   @Resource(name="accountService")
/*  38:    */   private AccountService accountService;
/*  39:    */   @Resource(name="assetsLbltsAccountRuleService")
/*  40:    */   private AssetsLbltsAccountRuleService assetsLbltsAccountRuleService;
/*  41:    */   @Resource(name="accountTransferService")
/*  42:    */   private AccountTransferService accountTransferService;
/*  43:    */   
/*  44:    */   @RequestMapping(value={"/listAllAccountingRule"}, produces={"application/json;charset=UTF-8"})
/*  45:    */   @ResponseBody
/*  46:    */   public String listAllAccountingRule()
/*  47:    */   {
/*  48: 55 */     ResponseModle responseModle = null;
/*  49:    */     try
/*  50:    */     {
/*  51: 57 */       List<AccountingRuleVO> accountingRuleList = this.accountService.listAllAccountingRule();
/*  52: 58 */       responseModle = new ResponseModle("success", accountingRuleList);
/*  53:    */     }
/*  54:    */     catch (Exception e)
/*  55:    */     {
/*  56: 60 */       LogUtil.error("查询账户记账规则异常", e);
/*  57: 61 */       responseModle = new ResponseModle("error", new ArrayList());
/*  58:    */     }
/*  59: 63 */     return JSON.toJSONString(responseModle);
/*  60:    */   }
/*  61:    */   
/*  62:    */   @RequestMapping(value={"/modifyAccountingRule"}, produces={"application/json;charset=UTF-8"})
/*  63:    */   @ResponseBody
/*  64:    */   public String modifyAccountingRule(HttpServletRequest request, HttpServletResponse response)
/*  65:    */   {
/*  66: 75 */     boolean excuteFlag = false;
/*  67:    */     try
/*  68:    */     {
/*  69: 77 */       String modifyType = request.getParameter("modifyType");
/*  70: 78 */       AccountingRuleVO accountingRuleVO = (AccountingRuleVO)JSON.parseObject(request.getParameter("accountingRuleVO"), AccountingRuleVO.class);
/*  71: 80 */       if ("insert".equals(modifyType)) {
/*  72: 81 */         excuteFlag = this.accountService.insertAccountingRule(accountingRuleVO);
/*  73: 82 */       } else if ("update".equals(modifyType)) {
/*  74: 83 */         excuteFlag = this.accountService.updateAccountingRule(accountingRuleVO);
/*  75:    */       }
/*  76:    */     }
/*  77:    */     catch (Exception e)
/*  78:    */     {
/*  79: 86 */       LogUtil.error("更改账户记账规则异常", e);
/*  80:    */     }
/*  81: 88 */     return JSON.toJSONString(assemblyResponseData(excuteFlag, null));
/*  82:    */   }
/*  83:    */   
/*  84:    */   @RequestMapping(value={"/modifySubAccountingRule"}, produces={"application/json;charset=UTF-8"})
/*  85:    */   @ResponseBody
/*  86:    */   public String modifySubAccountingRule(HttpServletRequest request, HttpServletResponse response)
/*  87:    */   {
/*  88:100 */     boolean excuteFlag = false;
/*  89:    */     try
/*  90:    */     {
/*  91:102 */       String modifyType = request.getParameter("modifyType");
/*  92:103 */       SubAccountingRuleVO subAccountingRuleVO = (SubAccountingRuleVO)JSON.parseObject(request.getParameter("subAccountingRuleVO"), SubAccountingRuleVO.class);
/*  93:105 */       if ("insert".equals(modifyType)) {
/*  94:106 */         excuteFlag = this.accountService.insertSubAccountRule(subAccountingRuleVO);
/*  95:107 */       } else if ("update".equals(modifyType)) {
/*  96:108 */         excuteFlag = this.accountService.updateSubAccountingRule(subAccountingRuleVO);
/*  97:    */       }
/*  98:    */     }
/*  99:    */     catch (Exception e)
/* 100:    */     {
/* 101:111 */       LogUtil.error("更改账户记账子规则异常", e);
/* 102:    */     }
/* 103:113 */     return JSON.toJSONString(assemblyResponseData(excuteFlag, null));
/* 104:    */   }
/* 105:    */   
/* 106:    */   @RequestMapping(value={"/listAllAssetsLbltsAccountRule"}, produces={"application/json;charset=UTF-8"})
/* 107:    */   @ResponseBody
/* 108:    */   public String listAllAssetsLbltsAccountRule()
/* 109:    */   {
/* 110:123 */     ResponseModle responseModle = null;
/* 111:    */     try
/* 112:    */     {
/* 113:126 */       List<AssetsLbltsAccountRuleVO> accountingRuleList = this.assetsLbltsAccountRuleService.listAllAssetsLbltsAccountRule();
/* 114:127 */       responseModle = new ResponseModle("success", accountingRuleList);
/* 115:    */     }
/* 116:    */     catch (Exception e)
/* 117:    */     {
/* 118:129 */       LogUtil.error("查询所有资产/负债账户记账规则异常", e);
/* 119:130 */       responseModle = new ResponseModle("error", new ArrayList());
/* 120:    */     }
/* 121:132 */     return JSON.toJSONString(responseModle);
/* 122:    */   }
/* 123:    */   
/* 124:    */   @RequestMapping(value={"/modifyAssetsLbltsAccountRule"}, produces={"application/json;charset=UTF-8"})
/* 125:    */   @ResponseBody
/* 126:    */   public String modifyAssetsLbltsAccountRule(HttpServletRequest request, HttpServletResponse response)
/* 127:    */   {
/* 128:144 */     boolean excuteFlag = false;
/* 129:    */     try
/* 130:    */     {
/* 131:146 */       String modifyType = request.getParameter("modifyType");
/* 132:    */       
/* 133:148 */       AssetsLbltsAccountRuleVO assetsLbltsAccountRuleVO = (AssetsLbltsAccountRuleVO)JSON.parseObject(request.getParameter("assetsLbltsAccountRuleVO"), AssetsLbltsAccountRuleVO.class);
/* 134:149 */       if ("insert".equals(modifyType)) {
/* 135:150 */         excuteFlag = this.assetsLbltsAccountRuleService.insertAssetsLbltsAccountRule(assetsLbltsAccountRuleVO);
/* 136:151 */       } else if ("update".equals(modifyType)) {
/* 137:152 */         excuteFlag = this.assetsLbltsAccountRuleService.updateAssetsLbltsAccountRule(assetsLbltsAccountRuleVO);
/* 138:    */       }
/* 139:    */     }
/* 140:    */     catch (Exception e)
/* 141:    */     {
/* 142:155 */       LogUtil.error("更改资产/负债账户记账规则异常", e);
/* 143:    */     }
/* 144:157 */     return JSON.toJSONString(assemblyResponseData(excuteFlag, null));
/* 145:    */   }
/* 146:    */   
/* 147:    */   @RequestMapping(value={"/queryRecieverAccountingRule"}, produces={"application/json;charset=UTF-8"})
/* 148:    */   @ResponseBody
/* 149:    */   public AccountingRuleVO queryRecieverAccountingRule(HttpServletRequest request, HttpServletResponse response)
/* 150:    */   {
/* 151:    */     try
/* 152:    */     {
/* 153:164 */       String serviceNo = request.getParameter("serviceNo");
/* 154:165 */       String subServiceNo = request.getParameter("subServiceNo");
/* 155:166 */       AccountingRuleVO vo = this.accountService.queryRecieverAccountingRule(serviceNo, subServiceNo);
/* 156:167 */       LogUtil.debug("子服务代码为：========" + vo.getSubServiceNo() + ";科目代码为：" + vo.getSubSubjectCode() + ",有效性为：" + vo.getIsValid());
/* 157:168 */       return vo;
/* 158:    */     }
/* 159:    */     catch (Exception e)
/* 160:    */     {
/* 161:170 */       LogUtil.error("更改资产/负债账户记账规则异常", e);
/* 162:    */     }
/* 163:171 */     return null;
/* 164:    */   }
/* 165:    */   
/* 166:    */   @RequestMapping(value={"/saveAccountTransfer"}, produces={"application/json;charset=UTF-8"})
/* 167:    */   @ResponseBody
/* 168:    */   public String saveAccountTransfer(HttpServletRequest request, HttpServletResponse response)
/* 169:    */   {
/* 170:    */     try
/* 171:    */     {
/* 172:186 */       String accountTransfer = request.getParameter("accountTransfer");
/* 173:187 */       AccountTransferVO tranVO = (AccountTransferVO)JSON.parseObject(accountTransfer, AccountTransferVO.class);
/* 174:188 */       Subject subject = SecurityUtils.getSubject();
/* 175:189 */       String managerId = (String)subject.getSession().getAttribute("dzSessionAttrUserId");
/* 176:190 */       tranVO.setCreatedBy(managerId);
/* 177:191 */       this.accountTransferService.saveAccountTransfer(tranVO);
/* 178:192 */       ResponseModle responseModle = new ResponseModle("success", null);
/* 179:193 */       return JSON.toJSONString(responseModle);
/* 180:    */     }
/* 181:    */     catch (Exception e)
/* 182:    */     {
/* 183:195 */       LogUtil.error("划拨交易异常", e);
/* 184:196 */       ResponseModle responseModle = new ResponseModle("error", "划拨交易异常，请稍后再试");
/* 185:197 */       return JSON.toJSONString(responseModle);
/* 186:    */     }
/* 187:    */   }
/* 188:    */   
/* 189:    */   @RequestMapping(value={"/queryTranInfosForRefund"}, produces={"application/json;charset=UTF-8"})
/* 190:    */   @ResponseBody
/* 191:    */   public String queryTranInfosForRefund(HttpServletRequest request, HttpServletResponse response)
/* 192:    */   {
/* 193:    */     try
/* 194:    */     {
/* 195:212 */       String accountTransfer = request.getParameter("searchModel");
/* 196:213 */       JSONObject searchObj = JSON.parseObject(accountTransfer);
/* 197:214 */       String mobileNo = searchObj.getString("mobileNo");
/* 198:215 */       String startDate = searchObj.getString("startDate");
/* 199:216 */       String endDate = searchObj.getString("endDate");
/* 200:217 */       Map searchMap = new HashMap();
/* 201:218 */       if (StringUtils.isNotBlank(mobileNo)) {
/* 202:219 */         searchMap.put("mobileNo", mobileNo);
/* 203:    */       }
/* 204:221 */       if (StringUtils.isNotBlank(startDate)) {
/* 205:222 */         searchMap.put("startDate", DateUtil.parseToDate(startDate + " 00:00:00"));
/* 206:    */       }
/* 207:224 */       if (StringUtils.isNotBlank(endDate)) {
/* 208:225 */         searchMap.put("endDate", DateUtil.parseToDate(endDate + " 23:59:59"));
/* 209:    */       }
/* 210:227 */       List<TranInfoVO> tranInfoList = this.accountTransferService.queryTranInfosForRefund(searchMap);
/* 211:228 */       ResponseModle responseModle = new ResponseModle("success", tranInfoList);
/* 212:229 */       return JSON.toJSONString(responseModle);
/* 213:    */     }
/* 214:    */     catch (Exception e)
/* 215:    */     {
/* 216:231 */       LogUtil.error("查询交易信息异常", e);
/* 217:232 */       ResponseModle responseModle = new ResponseModle("error", "查询交易异常，请稍后再试");
/* 218:233 */       return JSON.toJSONString(responseModle);
/* 219:    */     }
/* 220:    */   }
/* 221:    */   
/* 222:    */   @RequestMapping(value={"/queryTranSubJrnl"}, produces={"application/json;charset=UTF-8"})
/* 223:    */   @ResponseBody
/* 224:    */   public String queryTranSubJrnl(HttpServletRequest request, HttpServletResponse response)
/* 225:    */   {
/* 226:247 */     ResponseModle responseModle = null;
/* 227:    */     try
/* 228:    */     {
/* 229:249 */       String tradeNo = request.getParameter("tradeNo");
/* 230:250 */       if (StringUtils.isBlank(tradeNo))
/* 231:    */       {
/* 232:251 */         responseModle = new ResponseModle("error", "交易流水号不能为空。");
/* 233:252 */         return JSON.toJSONString(responseModle);
/* 234:    */       }
/* 235:254 */       List<TranSubVO> tranSubList = this.accountTransferService.queryTranSubJrnl(tradeNo);
/* 236:255 */       responseModle = new ResponseModle("success", tranSubList);
/* 237:256 */       return JSON.toJSONString(responseModle);
/* 238:    */     }
/* 239:    */     catch (Exception e)
/* 240:    */     {
/* 241:258 */       LogUtil.error("查询交易明细信息异常", e);
/* 242:259 */       responseModle = new ResponseModle("error", "查询交易明细异常，请稍后再试");
/* 243:    */     }
/* 244:260 */     return JSON.toJSONString(responseModle);
/* 245:    */   }
/* 246:    */   
/* 247:    */   @RequestMapping(value={"/saveRefundInfo"}, produces={"application/json;charset=UTF-8"})
/* 248:    */   @ResponseBody
/* 249:    */   public String saveRefundInfo(HttpServletRequest request, HttpServletResponse response)
/* 250:    */   {
/* 251:273 */     ResponseModle responseModle = null;
/* 252:    */     try
/* 253:    */     {
/* 254:275 */       String tranInfo = request.getParameter("tranInfo");
/* 255:276 */       String subJrnlList = request.getParameter("subJrnlList");
/* 256:277 */       List<TranSubVO> tranSubList = JSON.parseArray(subJrnlList, TranSubVO.class);
/* 257:278 */       TranInfoVO tranInfoVO = (TranInfoVO)JSON.parseObject(tranInfo, TranInfoVO.class);
/* 258:279 */       this.accountTransferService.saveRefundInfo(tranInfoVO, tranSubList);
/* 259:280 */       responseModle = new ResponseModle("success", null);
/* 260:281 */       return JSON.toJSONString(responseModle);
/* 261:    */     }
/* 262:    */     catch (Exception e)
/* 263:    */     {
/* 264:283 */       LogUtil.error("保存退款交易异常", e);
/* 265:284 */       responseModle = new ResponseModle("error", "保存退款交易异常，请稍后再试");
/* 266:    */     }
/* 267:285 */     return JSON.toJSONString(responseModle);
/* 268:    */   }
/* 269:    */   
/* 270:    */   @RequestMapping(value={"/saveAdjustAccount"}, produces={"application/json;charset=UTF-8"})
/* 271:    */   @ResponseBody
/* 272:    */   public String saveAdjustAccount(HttpServletRequest request, HttpServletResponse response)
/* 273:    */   {
/* 274:298 */     ResponseModle responseModle = null;
/* 275:    */     try
/* 276:    */     {
/* 277:300 */       String adjustAccount = request.getParameter("adjustAccount");
/* 278:301 */       AccountTransferVO accountTranferVO = (AccountTransferVO)JSON.parseObject(adjustAccount, AccountTransferVO.class);
/* 279:302 */       this.accountTransferService.saveAdjustAccount(accountTranferVO);
/* 280:303 */       responseModle = new ResponseModle("success", null);
/* 281:304 */       return JSON.toJSONString(responseModle);
/* 282:    */     }
/* 283:    */     catch (Exception e)
/* 284:    */     {
/* 285:306 */       LogUtil.error("保存调账异常", e);
/* 286:307 */       responseModle = new ResponseModle("error", "保存调账异常，请稍后再试");
/* 287:    */     }
/* 288:308 */     return JSON.toJSONString(responseModle);
/* 289:    */   }
/* 290:    */ }


/* Location:           F:\work\pengyu\mainServer\WEB-INF\classes\
 * Qualified Name:     tt.dz.web.controller.financial.AccountingController
 * JD-Core Version:    0.7.0.1
 */